<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
</html>
<script type="text/javascript">
	let userinfo = [];
	// 模拟获取 用户数据 订单数据 商品数据
	function getUsers(){
		setTimeout(() => {
			userinfo.push({
				name : '小明',
				orders:[]
			})
			console.log('ok')
			iterator.next();
		},1000)
	}
	function getOrders(){
		setTimeout(() => {
			userinfo[0].orders.push({
				orderid : 1,
				items : []
			});
			userinfo[0].orders.push({
				orderid : 2,
				items : []
			});
			console.log(userinfo[0])
			iterator.next();
		},1000)
	}
	function getItems(){
		setTimeout(() => {
			userinfo[0].orders[0].items.push('西瓜','苹果','香蕉');
			userinfo[0].orders[1].items.push('桃子','菠萝');
			console.log(userinfo[0])
		},1000)
	}
	function * buyer(){
		yield getUsers();
		yield getOrders();
		yield getItems();
	}
	let iterator = buyer();
	iterator.next();
	
</script>